/*
 * Package il.ac.biu.cs.grossmm.api.data
 * File NodeInspector.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 */

package il.ac.biu.cs.grossmm.api.flow;

import il.ac.biu.cs.grossmm.api.OperationFailedException;
import il.ac.biu.cs.grossmm.api.data.Node;
import il.ac.biu.cs.grossmm.api.data.Nodeset;
import il.ac.biu.cs.grossmm.api.data.Property;
import il.ac.biu.cs.grossmm.api.data.Unique;

import java.util.Set;

/**
 * Provides tools to read data associated with data-nodes
 */
public interface NodeInspector {

	/**
	 * Gets value currently associated with a property of a node instance
	 * 
	 * @param <N>
	 *            node interface
	 * @param
	 *            <P>
	 *            property value class
	 * @param node
	 *            the node
	 * @param property
	 *            the property within this node
	 * @return value of the specified property of the specified node
	 * @throws OperationFailedException
	 */
	<N, P> P getValue(Node<N> node, Property<N, P> property)
		throws OperationFailedException;

	/**
	 * Gets subnodes within a specified node-set of a specified node
	 * 
	 * @param <N>
	 *            node interface
	 * @param <S>
	 *            node-set value class
	 * @param node
	 *            the node
	 * @param nods
	 *            the node-set within this node
	 * @return nodes within the specified node-set of the specified node
	 * @throws OperationFailedException
	 */
	<N, S> Set<Node<S>> getSubnodes(Node<N> node, Nodeset<N, S> nods)
		throws OperationFailedException;

	/**
	 * Gets a subnode within a specified node-set with a specified value of a
	 * unique property
	 * 
	 * @param <N>
	 *            node interface
	 * @param <S>
	 *            node-set value class
	 * @param <U>
	 *            unique property
	 * @param node
	 *            the node
	 * @param nodeSet
	 *            the node-set within this node
	 * @param unique
	 *            unique property
	 * @param value
	 *            value to match
	 * @return subnode within the specified node-set with the specified value of
	 *         a unique property
	 * @throws OperationFailedException
	 */
	<N, S, U> Node<S> getSubnode(Node<N> node, Nodeset<N, S> nodeSet,
		Unique<S, U> unique, U value) throws OperationFailedException;

	String toString(Node node);
}
